package com.zzt.mylotterykill.service;

import com.zzt.mylotterykill.data.OptionData;
import com.zzt.mylotterykill.entity.BetDetail;
import com.zzt.mylotterykill.entity.Option;
import com.zzt.mylotterykill.enums.GameEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

@Service
@Slf4j
public class BetDetailService {


    public List<BetDetail> getBetDetails(GameEnum gameEnum, long num) {
        //获取选项
        List<BetDetail> betDetails = new ArrayList<>();
        Random random = new Random();
        for(long i = 1; i <= num; i++){
            Option option = getRandomOption(gameEnum);
            BetDetail betDetail = new BetDetail(
                    gameEnum,
                    option.getOption(),
                    option.getValue(),
                    new BigDecimal(random.nextInt(1,10))
            );
            betDetails.add(betDetail);
        }
        return betDetails;
    }


    public static Option getRandomOption(GameEnum gameEnum){
        Random random = new Random();
        List<List<Option>> optionListList = OptionData.getOptionList(gameEnum);
        List<Option> options = optionListList.get(random.nextInt(optionListList.size()));
        return options.get(random.nextInt(options.size()));
    }
}
